home *** CD-ROM | disk | FTP | other *** search
/ Executor 2.0 / executorv2.0.iso / pc / dos / extra / source / browser / browser.hqx / Browser / iconcontrol ƒ / getrects.c next >
Encoding:
C/C++ Source or Header  |  1995-07-05  |  1.6 KB  |  52 lines

  1. /* #include "go.h" */
  2. #include "iconcontrol.h"
  3. #define NDEBUG
  4. #include <assert.h>
  5.  
  6. #include "getrects.proto.h"
  7.  
  8. void
  9. getrects (ControlHandle c, Rect * textr, Rect * iconr)
  10. {
  11.   short len, mid;
  12.   short textsize, textfont;
  13.   WindowPtr saveport;
  14.  
  15.   GetPort (&saveport);
  16.   SetPort ((*c)->contrlOwner);
  17.   textfont = (*c)->contrlOwner->txFont;
  18.   textsize = (*c)->contrlOwner->txSize;
  19.   TextSize (FONTSIZE);
  20.   TextFont (applFont);
  21.   len = StringWidth ((*c)->contrlTitle);
  22.   switch ((*(item **) (*c)->contrlData)->view)
  23.     {
  24.     case ICONVIEW:
  25.       mid = ((*c)->contrlRect.right + (long) (*c)->contrlRect.left) / 2;
  26.       SetRect (textr, mid - len / 2 - 1, (*c)->contrlRect.top + ICONSIZE,
  27.            mid + len / 2 + 1, (*c)->contrlRect.bottom);
  28.       SetRect (iconr, mid - ICONSIZE / 2, (*c)->contrlRect.top,
  29.            mid + ICONSIZE / 2, (*c)->contrlRect.top + ICONSIZE);
  30.       break;
  31.     case ICSVIEW:
  32.       mid = ((*c)->contrlRect.top + (*c)->contrlRect.bottom) / 2;
  33.       SetRect (textr, (*c)->contrlRect.left + ICSSIZE, (*c)->contrlRect.top,
  34.         (*c)->contrlRect.left + ICSSIZE + len, (*c)->contrlRect.bottom);
  35.       SetRect (iconr, (*c)->contrlRect.left, mid - ICSSIZE / 2,
  36.            (*c)->contrlRect.left + ICSSIZE, mid + ICSSIZE / 2);
  37.       break;
  38.     case LISTVIEW:
  39.       SetRect (textr, (*c)->contrlRect.left, (*c)->contrlRect.top,
  40.        (*c)->contrlOwner->portRect.right - 15, (*c)->contrlRect.bottom);
  41.       SetRect (iconr, 0, 0, 0, 0);
  42.       break;
  43.     default:
  44.       DebugStr ((StringPtr) "\pUnknown Control view");
  45.       assert (0);
  46.       break;
  47.     }
  48.   TextSize (textsize);
  49.   TextFont (textfont);
  50.   SetPort (saveport);
  51. }
  52.